package com.ziqikeji.strategy;

/**
 * 上下文 类
 * 屏蔽其余技术细节，模拟使用策略的场景类
 */
public class StrategyContext {
    private Strategy strategy;

    public StrategyContext() {
    }

    public StrategyContext(Strategy strategy) {
        this.strategy = strategy;
    }

    /**
     * 支付流程
     */
    public void payment() {
        //商品原价
        double price = 120;

        double promotionPrice = strategy.calPrice(price);
        System.out.println(promotionPrice);
    }

    public void setStrategy(Strategy strategy) {
        this.strategy = strategy;
    }
}
